/*
 * DxfTEXT.java
 *
 * Created on 6 de Dezembro de 2007, 10:47
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package importadorDXF;

import mathematics.Point3D;

/**
 *
 * @author rafaelbuck
 */
public class DxfTEXT extends DxfEntity
{

    public boolean setGroup(short grpNr, float fval)
    {
        switch(grpNr)
        {
        case 10: // '\n'
        case 20: // '\024'
        case 30: // '\036'
            setCoord(position, grpNr / 10, fval);
            return true;

        case 11: // '\013'
        case 21: // '\025'
        case 31: // '\037'
            if(adjust == null)
                adjust = new Point3D();
            setCoord(adjust, grpNr / 10, fval);
            return true;

        case 40: // '('
            textHeight = fval;
            return true;

        case 41: // ')'
            aspect = fval;
            return true;

        case 50: // '2'
            angle = (float)(((double)fval / 180D) * 3.1415926535897931D);
            return true;

        case 51: // '3'
            slant = (float)(((double)fval / 180D) * 3.1415926535897931D);
            return true;
        }
        return super.setGroup(grpNr, fval);
    }

    public boolean setGroup(short grpNr, int ival)
    {
        switch(grpNr)
        {
        case 71: // 'G'
            mirror = (short)ival;
            return true;

        case 72: // 'H'
            hAdjust = (short)ival;
            return true;

        case 73: // 'I'
            vAdjust = (short)ival;
            return true;
        }
        return super.setGroup(grpNr, ival);
    }

    public boolean setGroup(short grpNr, String str)
    {
        switch(grpNr)
        {
        case 1: // '\001'
            text = str;
            return true;

        case 7: // '\007'
            styleName = str;
            return true;
        }
        return super.setGroup(grpNr, str);
    }

    public void convert(DxfConverter converter, DxfFile dxf, Object collector)
    {
        converter.convert(this, dxf, collector);
    }

    public final Point3D getPosition()
    {
        return position;
    }

    public final float getTextHeight()
    {
        return textHeight;
    }

    public final String getText()
    {
        return text;
    }

    public final float getRotation()
    {
        return angle;
    }

    public final float getAspectRatio()
    {
        return aspect;
    }

    public final float getSlant()
    {
        return slant;
    }

    public final String getStyleName()
    {
        return styleName;
    }

    public final short getMirror()
    {
        return mirror;
    }

    public final short getHAdjust()
    {
        return hAdjust;
    }

    public final short getVAdjust()
    {
        return vAdjust;
    }

    public final Point3D getAdjust()
    {
        return adjust;
    }

    /** Creates a new instance of DxfTEXT */
    public DxfTEXT()
    {
        position = new Point3D();
        aspect = 1.0F;
    }

    public static final short MIRROR_X = 2;
    public static final short MIRROR_Y = 4;
    public static final short H_LEFT = 0;
    public static final short H_CENTER = 1;
    public static final short H_RIGHT = 2;
    public static final short H_ADJUST = 3;
    public static final short H_MID = 4;
    public static final short H_FITTED = 5;
    public static final short V_BASE = 0;
    public static final short V_BOTTOM = 1;
    public static final short V_CENTER = 2;
    public static final short V_TOP = 3;
    protected Point3D position;
    protected float textHeight;
    protected String text;
    protected float angle;
    protected float aspect;
    protected float slant;
    protected String styleName;
    protected short mirror;
    protected short hAdjust;
    protected short vAdjust;
    protected Point3D adjust;
}